package org.polyforms.repository.datanucleus;

import javax.persistence.EntityManager;

import org.datanucleus.ObjectManager;
import org.datanucleus.metadata.AbstractClassMetaData;

final class DatanucleusUtil {
    protected DatanucleusUtil() {
        throw new UnsupportedOperationException();
    }

    protected static ObjectManager getObjectManager(final EntityManager entityManager) {
        return (ObjectManager) entityManager.getDelegate();
    }

    protected static AbstractClassMetaData getMetaData(final EntityManager entityManager, final Class<?> entityClass) {
        final ObjectManager objectManager = getObjectManager(entityManager);
        return objectManager.getMetaDataManager().getMetaDataForClass(entityClass,
                objectManager.getClassLoaderResolver());
    }
}
